<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>操作类名的方式设置样式</title>
    <style>
      div {
        width: 200px;
        height: 200px;
        background-color: pink;
        margin: 100px auto 0;
        transition: all 0.5s;
      }
      /* 要操作的类名 */
      .current {
        background-color: red;
        transform: rotate(360deg);
      }
    </style>
    <script src="lib/jQuery-v3.6.0.min.js"></script>
  </head>
  <body>
    <div></div>

    <script>
      $(function () {
        $('div').click(function () {
          // 添加类名
          // $(this).addClass('current')

          // 切换类名
          $(this).toggleClass('current')
        })
      })
    </script>
  </body>
</html>
